from jili.calc import calcor_base
import numpy as np
class PSY(calcor_base):
    def __init__(self,ta_arg={}):
        self.out = ["PSY"]
        self.input = ["close"]
        self.parameters = {"timeperiod":12}
        super().__init__(ta_arg)
        self.batch=self.parameters["timeperiod"]+1
        self.lookback = self.batch - 1
    def calc(self):
        data = self.hisbars[self.input[0]]
        data=np.diff(data)
        n=len(data[data>0])/len(data)
        return n